const http = require('http')
const qs = require('querystring')
const server = http.createServer()

server.on('request',(req,res) =>{
    const cookie = qs.parse(req.headers.cookie,";")
    console.log(cookie);
    if(cookie.isvisited === 'yes'){
        res.end('不要太贪心')
    }else{
        res.writeHeader(200,{
            "content-type":'text:html;charset=utf-8',
            'set-cookie':['isvisited=yes','test=ook']
        })
        res.end('我要送你99朵玫瑰花')
    }
})

server.listen(3000,()=>{
    console.log('http://127.0.0.1:3000');
    
})